package com.esri.core.geodatabase;

import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.Feature;
import com.esri.core.symbol.Symbol;
import com.esri.core.table.TableException;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/* loaded from: classes.dex */
public class ShapefileFeature implements Feature {
    private long a;
    private ShapefileFeatureTable b;
    private Geometry c;
    private Map<String, Object> d;

    @Override // com.esri.core.map.Feature
    public SpatialReference getSpatialReference() {
        return null;
    }

    @Override // com.esri.core.map.Feature
    public Symbol getSymbol() {
        return null;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public ShapefileFeature(long j, Map<String, Object> map, Geometry geometry, ShapefileFeatureTable shapefileFeatureTable) throws TableException {
        this.d = Collections.synchronizedMap(new LinkedHashMap());
        this.a = j;
        if (map != null) {
            HashMap hashMap = new HashMap();
            for (String str : map.keySet()) {
                hashMap.put(str, map.get(str));
                a(hashMap);
            }
        } else {
            a(map);
        }
        a(geometry);
        this.b = shapefileFeatureTable;
    }

    public ShapefileFeature(Map<String, Object> map, ShapefileFeatureTable shapefileFeatureTable) throws TableException {
        this(-1L, map, null, shapefileFeatureTable);
        a(map, this.c, shapefileFeatureTable);
    }

    public ShapefileFeature(Map<String, Object> map, Geometry geometry, ShapefileFeatureTable shapefileFeatureTable) throws TableException {
        this(-1L, map, geometry, shapefileFeatureTable);
        a(map, geometry, shapefileFeatureTable);
    }

    @Override // com.esri.core.map.Feature
    public Object getAttributeValue(String str) {
        Map<String, Object> map = this.d;
        if (map == null) {
            return null;
        }
        return map.get(str);
    }

    @Override // com.esri.core.map.Feature
    public Map<String, Object> getAttributes() {
        if (this.d == null) {
            return null;
        }
        return new LinkedHashMap(this.d);
    }

    @Override // com.esri.core.map.Feature
    public long getId() {
        return this.a;
    }

    @Override // com.esri.core.map.Feature
    public Geometry getGeometry() {
        return this.c;
    }

    public String toString() {
        return "ShapefileFeature [geometry=" + this.c + ", attributes=" + this.d + ", table=" + this.b + ", oid=" + this.a + "]";
    }

    void a(Map<String, Object> map, Geometry geometry, ShapefileFeatureTable shapefileFeatureTable) throws TableException {
        if (map != null) {
            for (String str : map.keySet()) {
                if (shapefileFeatureTable.getField(str) == null) {
                    throw new TableException(str + " not found in schema.");
                }
            }
        }
        if (geometry == null || geometry.getType() == shapefileFeatureTable.getGeometryType()) {
            return;
        }
        throw new TableException("Geometry type of " + geometry.getType() + " does not match table geometry type of " + shapefileFeatureTable.getGeometryType() + ".");
    }

    private void a(Geometry geometry) {
        this.c = geometry;
    }

    private void a(Map<String, Object> map) {
        if (map != null && map.size() > 0) {
            this.d.putAll(map);
        } else {
            this.d.clear();
        }
    }
}
